//
//  MCMyCollectBaseVc.swift
//  MCBodyBuildingPro
//
//  Created by Renlvshijie on 2023/5/5.
//

import UIKit
import JXSegmentedView
import SnapKit
import QMUIKit

class MCMyCollectBaseVc: MCBaseVc {
    
    var segmentedDataSource:JXSegmentedTitleDataSource!
    let segmentedView = JXSegmentedView()
    lazy var listContainerView:JXSegmentedListContainerView! = {
        return JXSegmentedListContainerView(dataSource: self)
    }()
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.qmui_color(withHexString: "#F7F7F9")
        self.navigationItem.title = "我的收藏"
        //scrollView 滚动页面
        segmentedDataSource = JXSegmentedTitleDataSource()
        segmentedDataSource.isTitleColorGradientEnabled = true
        
        segmentedView.dataSource = segmentedDataSource
        segmentedView.delegate = self
        
       
        let indicator = JXSegmentedIndicatorLineView()
        indicator.indicatorWidth = 20
        segmentedView.indicators = [indicator]
        view.addSubview(segmentedView)
        
        segmentedView.listContainer = listContainerView
        
        view.addSubview(listContainerView)
        self.segmentedDataSource.titles = ["健身动作","健身器械","健康饮食"]
        segmentedView.snp.makeConstraints { make in
            make.left.equalTo(view.snp.left).offset(0)
            make.right.equalTo(view.snp.right).offset(0)
            make.top.equalTo(view.safeAreaLayoutGuide.snp.top).offset(0.0)
            make.height.equalTo(50.auto())
        }
        
        
        listContainerView.snp.makeConstraints { make in
            make.left.equalTo(view.snp.left).offset(0)
            make.right.equalTo(view.snp.right).offset(0)
            make.top.equalTo(segmentedView.snp.bottom).offset(0.0)
            make.bottom.equalTo(view.safeAreaLayoutGuide.snp.bottom).offset(0.0)
        }
        
        
    }
    
}

extension MCMyCollectBaseVc:JXSegmentedViewDelegate {
    func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {

    }
}

extension MCMyCollectBaseVc:JXSegmentedListContainerViewDataSource {
    func numberOfLists(in listContainerView:JXSegmentedListContainerView) -> Int {
        return 3
    }
    
    func listContainerView(_ listContainerView:JXSegmentedListContainerView, initListAt index: Int) -> JXSegmentedListContainerViewListDelegate {
         
        if index == 0 {
            let fitnessVc = MCFitnessVc.init()
          // fitnessVc.indexName = labelName
            return fitnessVc
        }else if index == 1 {
         
            let instrumentVc = MCInstrumentVc.init()
           // dietBaseVc.indexName = labelName
            return instrumentVc
        }else {
          
            let dietHealthVc = MCDietHealthVc.init()
          //  dietBaseVc.indexName = labelName
            return dietHealthVc
        }
       
    }
    
    
}
